<%- partial('../sidebar') %>

<div id='content'>
  <div class='panel'>
    <div class='header'>
      <ul class='breadcrumb'>
        <li><a href='/'>主页</a><span class='divider'>/</span></li>
        <li class='active'>账号编辑</li>
      </ul>
    </div>
    <div class='inner'>
      <% if (typeof(error) !== 'undefined' && error) { %>
      <div class="alert alert-error">
        <a class="close" data-dismiss="alert" href="#">&times;</a>
        <strong><%= error %></strong>
      </div>
      <% } %>
      <% if (typeof(success) !== 'undefined' && success) { %>
      <div class="alert alert-success">
        <strong><%= success %></strong>
      </div>
      <% } %>
      <form id='signup_form' class='form-horizontal' action='/usermanager/<%=_id%>/edit' method='post'>
        <div class='control-group'>
          <label class='control-label' for='loginname'>用户名</label>

          <div class='controls'>
            <% if (typeof(loginname) !== 'undefined') { %>
            <input class='input-xlarge' id='loginname' name='loginname' size='30' type='text' value='<%= loginname %>' readonly="readonly"/>
            <% } else { %>
            <input class='input-xlarge' id='loginname' name='loginname' size='30' type='text' value=''/>
            <% } %>
          </div>
        </div>

        <div class='control-group'>
          <label class='control-label' for='is_change_password'>修改密码</label>

          <div class='controls'>
            <input class='input-xlarge' id='is_change_password' name='is_change_password' type='checkbox'/>
          </div>
        </div>

        <div class='control-group hide change-password'>
          <label class='control-label' for='pass'>密码</label>

          <div class='controls'>
            <input class='input-xlarge' id='pass' name='pass' size='30' type='password'/>
          </div>
        </div>
        <div class='control-group hide change-password'>
          <label class='control-label' for='re_pass'>确认密码</label>

          <div class='controls'>
            <input class='input-xlarge' id='re_pass' name='re_pass' size='30' type='password'/>
          </div>
        </div>
        <div class='control-group'>
          <label class='control-label' for='email'>电子邮箱</label>

          <div class='controls'>
            <% if (typeof(email) !== 'undefined') { %>
            <input class='input-xlarge' id='email' name='email' size='30' type='text' value='<%= email %>' readonly="readonly"/>
            <% } else { %>
            <input class='input-xlarge' id='email' name='email' size='30' type='text'/>
            <% } %>
          </div>
        </div>
        <div class='control-group'>
          <label class='control-label' for='phone'>手机</label>

          <div class='controls'>
            <% if (typeof(phone) !== 'undefined') { %>
            <input class='input-xlarge' id='phone' name='phone' size='30' type='text' value='<%= phone %>'/>
            <% } else { %>
            <input class='input-xlarge' id='phone' name='phone' size='30' type='text'/>
            <% } %>
          </div>
        </div>
        <div class='control-group'>
          <label class='control-label' for='position'>职位</label>

          <div class='controls'>
            <% if (typeof(position) !== 'undefined') { %>
            <input class='input-xlarge' id='position' name='position' size='30' type='text' value='<%= position %>'/>
            <% } else { %>
            <input class='input-xlarge' id='position' name='position' size='30' type='text'/>
            <% } %>
          </div>
        </div>
        <div class='control-group'>
          <label class='control-label' for='user_role'>用户角色</label>

          <div class='controls'>
            <select class="form-control" name="user_role_code">
              <%-partial('../share/option',{collection:user_roles, as:'opt', val: user_role_code }) %>
            </select>
          </div>
        </div>
        <div class='control-group'>
          <label class='control-label' for='department'>部门</label>

          <div class='controls'>
            <select class="form-control" name="department_code">
              <%-partial('../share/option',{collection:departments, as:'opt', val: department_code}) %>
            </select>
          </div>
        </div>
        <div class='control-group'>
          <label class='control-label' for='is_block'>是否禁用</label>

          <div class='controls'>
              <label class="radio inline"><input type="radio" name="is_block" value="true" <% if(is_block==true) {%>checked<% } %>>禁用</label>
              <label class="radio inline"><input type="radio" name="is_block" value="false" <% if(is_block==false) {%>checked<% } %>>可用</label>
          </div>
        </div>

        <input type='hidden' name='_csrf' value='<%= csrf %>'/>

        <div class='form-actions'>
          <input type='submit' class='span-primary' value='保存'/>
        </div>
      </form>
    </div>
  </div>
</div>
<script>
jQuery(function($){
  $('#is_change_password').click(function(){
    $('.change-password').toggle();
  });
});
</script>